package me.wz.util.sdbc.spring;

import me.wz.util.sdbc.IDialect;
import me.wz.util.sdbc.dialect.H2;
import me.wz.util.sdbc.dialect.Mysql;
import me.wz.util.sdbc.dialect.Oracle;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@Component
@Lazy(false)
public class Dialect {
    public static final Map<String, IDialect> mapp = new HashMap<String, IDialect>();
    public static IDialect getDialect(String key){ return mapp.get(key.toLowerCase()); }

    @PostConstruct
    private void postConstruct(){
        mapp.put("h2", new H2());
        mapp.put("mysql", new Mysql());
        mapp.put("oracle", new Oracle());
    }
}
